package cn.ahaiahaixx.dp.chain;

/**
 * 管理职责链
 * 
 * @author Aiden Pearce
 *
 */
public class ChainManager {
  private Mychain head;
  private Mychain tail;

  public void add(Mychain chain) {
    if (head == null) {
      head = chain;
      tail = chain;
      return;
    }
    tail.setNext(chain);
    tail = chain;
  }

  public void show(String info) {
    // 处理职责链
    for (Mychain chain = head; chain != null; chain = chain.getNext()) {
      chain.doChain(info);
    }
  }
}
